<template>
  <div class="background-img">
    <PasswordForm @login="login" />
  </div>
</template>
<script>
import PasswordForm from "./components/PasswordForm.vue";
import res from "@/utils/menu.js";
export default {
  components: {
    PasswordForm
  },
  data() {
    return {
      obj:[
        {
          name:"upload_form",
          list:[
            {
              name:'水果:',
              value_name:'fruits',
              type:2,
              placeholder:'请选择',
              hide:true,
            },
            {
              name:'城市:',
              value_name:'city',
              type:1,
              placeholder:'请选择',
            },
            {
              name:'运动:',
              value_name:'sport',
              type:1,
              placeholder:'请选择',
            },
          ]
        },
        {
          name:"menuTwo_form",
          list:[
            {
              name:'水果:',
              value_name:'fruits',
              type:2,
              placeholder:'请选择',
            },
            {
              name:'运动:',
              value_name:'sport',
              type:1,
              hide: true,
              placeholder:'请选择',
            },
          ]
        },
      ]
    };
  },
  created() {
    this.clean();
  },
  methods: {
    async login() {
      localStorage.setItem("jm_token", res.data.token);
      // this.$store.commit("setToken", res.data.token);
      localStorage.setItem("jm_menu", JSON.stringify(res.data.menu));
      this.getUserForm()
      setTimeout(() => {
        this.$router.push({ path: "/" });
      }, 100);
    },
    clean() {
      localStorage.removeItem("jm_token");
      localStorage.removeItem("jm_menu");
    },
    //获取用户配置的搜索表单
    getUserForm(){
      this.obj.forEach((item) => {
        // this.$TOOL.session.set(item.table_name, JSON.parse(item.table_config));
        sessionStorage.setItem(item.name, JSON.stringify(item.list));
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.background-img {
  background-image: url("./img/img.png");
  background-size: cover;
  background-position: center;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
}
</style>
